package com.techwells.learningkites.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;

import com.techwells.learningkites.database.CourseCategoryDao;
import com.techwells.learningkites.database.CourseDao;
import com.techwells.learningkites.database.LessonDao;
import com.techwells.learningkites.database.LessonVideoDao;
import com.techwells.learningkites.database.VideoCategoryDao;
import com.techwells.learningkites.database.VideoDao;
import com.techwells.learningkites.database.VideoDetailDao;
import com.techwells.learningkites.database.SerialDao;
import com.techwells.learningkites.database.WordDao;
import com.techwells.learningkites.database.SentenceDao;
import com.techwells.learningkites.database.TestDao;
import com.techwells.learningkites.database.FavoriteVideoDao;
import com.techwells.learningkites.database.FavoriteWordDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * Master of DAO (schema version 1): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 1;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
        CourseCategoryDao.createTable(db, ifNotExists);
        CourseDao.createTable(db, ifNotExists);
        LessonDao.createTable(db, ifNotExists);
        LessonVideoDao.createTable(db, ifNotExists);
        VideoCategoryDao.createTable(db, ifNotExists);
        VideoDao.createTable(db, ifNotExists);
        VideoDetailDao.createTable(db, ifNotExists);
        SerialDao.createTable(db, ifNotExists);
        WordDao.createTable(db, ifNotExists);
        SentenceDao.createTable(db, ifNotExists);
        TestDao.createTable(db, ifNotExists);
        FavoriteVideoDao.createTable(db, ifNotExists);
        FavoriteWordDao.createTable(db, ifNotExists);
    }
    
    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
        CourseCategoryDao.dropTable(db, ifExists);
        CourseDao.dropTable(db, ifExists);
        LessonDao.dropTable(db, ifExists);
        LessonVideoDao.dropTable(db, ifExists);
        VideoCategoryDao.dropTable(db, ifExists);
        VideoDao.dropTable(db, ifExists);
        VideoDetailDao.dropTable(db, ifExists);
        SerialDao.dropTable(db, ifExists);
        WordDao.dropTable(db, ifExists);
        SentenceDao.dropTable(db, ifExists);
        TestDao.dropTable(db, ifExists);
        FavoriteVideoDao.dropTable(db, ifExists);
        FavoriteWordDao.dropTable(db, ifExists);
    }
    
    public static abstract class OpenHelper extends SQLiteOpenHelper {

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }
    
    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

    public DaoMaster(SQLiteDatabase db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(CourseCategoryDao.class);
        registerDaoClass(CourseDao.class);
        registerDaoClass(LessonDao.class);
        registerDaoClass(LessonVideoDao.class);
        registerDaoClass(VideoCategoryDao.class);
        registerDaoClass(VideoDao.class);
        registerDaoClass(VideoDetailDao.class);
        registerDaoClass(SerialDao.class);
        registerDaoClass(WordDao.class);
        registerDaoClass(SentenceDao.class);
        registerDaoClass(TestDao.class);
        registerDaoClass(FavoriteVideoDao.class);
        registerDaoClass(FavoriteWordDao.class);
    }
    
    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }
    
    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }
    
}
